package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConTouristProblem;
import com.htgd.gardenexpo.dao.GeConTouristProblemDao;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.service.GeConTouristProblemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 常见问题表(GeConTouristProblem)表服务实现类
 *
 * @author makejava
 * @since 2021-06-09 14:40:58
 */
@Service("geConTouristProblemService")
public class GeConTouristProblemServiceImpl implements GeConTouristProblemService {
    @Resource
    private GeConTouristProblemDao geConTouristProblemDao;

    /**
     * 通过ID查询单条数据
     *
     * @param problemId 主键
     * @return 实例对象
     */
    @Override
    public GeConTouristProblem queryById(Integer problemId) {
        return this.geConTouristProblemDao.queryById(problemId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConTouristProblem> queryAllByLimit(int offset, int limit) {
        return this.geConTouristProblemDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<GeConTouristProblem> getAllProblemByValue(PageQuery pageQuery) {
        return this.geConTouristProblemDao.getAllProblemByValue(pageQuery);
    }

    @Override
    public List<GeConTouristProblem> getAllProblemByValueNoContent(PageQuery pageQuery) {
        return this.geConTouristProblemDao.getAllProblemByValueNoContent(pageQuery);
    }

    /**
     * 新增数据
     *
     * @param geConTouristProblem 实例对象
     * @return 实例对象
     */
    @Override
    public GeConTouristProblem insert(GeConTouristProblem geConTouristProblem) {
        this.geConTouristProblemDao.insert(geConTouristProblem);
        return geConTouristProblem;
    }

    /**
     * 修改数据
     *
     * @param geConTouristProblem 实例对象
     * @return 实例对象
     */
    @Override
    public GeConTouristProblem update(GeConTouristProblem geConTouristProblem) {
        this.geConTouristProblemDao.update(geConTouristProblem);
        return this.queryById(geConTouristProblem.getProblemId());
    }

    /**
     * 通过主键删除数据
     *
     * @param problemId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer problemId) {
        return this.geConTouristProblemDao.deleteById(problemId) > 0;
    }
}
